﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CBMS.Interfaces;
using CBMS.Models;
using System.Data.Objects.DataClasses;
using System.Data.Objects; 
using System.Collections;
using CBMS.Objects;
using System.Data.Objects.SqlClient;
using CBMS.Common;
using System.Data.Common;
using System.Data.EntityClient;
using System.Data;
using System.Globalization;
using System.Dynamic;
namespace CBMS.Business
{
    public class BranchRepository : BaseEntityRepository<Branch>, IBranchRepository
    {
        public BranchRepository()
            : base()
        {

        }
        public IList<ItemDTO> GetAllToComboBox()
        {
            IList<ItemDTO> lstResult = new List<ItemDTO>();
            try
            {
                var emp = (from n in DbContext.Branchs
                           select new 
                           {
                               Id = n.branch_id,
                               Name = n.branch_name
                           }).ToList();
                 int iRowsCount = emp.Count;
                 for (int i = 0; i < iRowsCount; i++)
                 {
                     ItemDTO item = new ItemDTO(emp[i].Id.ToString(), emp[i].Name);
                     lstResult.Add(item);
                 }
                return lstResult;
            }
            catch
            {
                return new List<ItemDTO>(); 
            }          
           
        }
       
    }
}